<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <!--如果是IE 就以标准渲染-->
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />

    <!-- 视窗——————响应式布局 -->
    <!-- <meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=yes,minimum-scale=0.5" /> -->
    <meta name='viewport' content='width=device-width,initial-scale=1.0,minimum-scale=0.5, maximum-scale=5.0' />

    <!--当前页面的三要素-->
    <title>运维系统-深中通道搅拌站</title>
    <meta name="description" content="聚能优电" />
    <meta http-equiv="keywords" content="聚能优电" />
    <script type="text/javascript" src="./js/verify.js"></script>
    <script type="text/javascript" src="./js/common/commonfuntion.js"></script>
    <!-- css -->
    <link rel="stylesheet" type="text/css" href="./css/common/common.css" />
    <link rel="stylesheet" type="text/css" href="./css/jquery-accordion-menu.css" />
    <link rel="stylesheet" type="text/css" href="./css/mainmonitor_sz.css" />
</head>

<body>
    <div id="container" class="mainmonitor_sz">
        <div class="mainmonitor_sz_01">
            <!--主屏内容-->
            <div class="mainmonitor_sz_screen">
                <div class="m_title">
                    <a href="JavaScript:history.go(-1);" class="back">
                        <img src="./images/back.svg" alt="" />
                    </a>
                    <span class="tit">云南滇中引水项目-各支洞</span>
                </div>
                <div class="m_content">
                    <header class="tabHead" id="tabHead">
                        
                    </header>
                    <article class="khfxWarp khfxWarpaa" id="khfxWarp">



                        
                    </article>
                </div>
            </div>
        </div>
    </div>

    <script>
        (function (win, doc) {
            var docEl = doc.documentElement || document.body; //获取HTML标签

            var container = doc.getElementById("container"); //container元素
            //判断是移动端设备还是PC,移动 就采用'orientationchange',横竖屏事件，PC端就采用onresize，窗口改变时间
            var resize =
                "onorientationchange" in win ? "orientationchange" : "resize";

            function rem() {
                docEl.style.fontSize = 100 * (container.clientWidth / 750) + "px";
            }

            //监听'DOMContent事件:DOM加载完成执行,如果DOMContent事件，那么执行rem函数
            doc.addEventListener("DOMContentLoaded", rem, false);

            //win下监听resize事件,如果resize事件，那么执行rem函数
            win.addEventListener(resize, rem, false);
        })(window, document);
    </script>
    <!-- js -->
    <script type="text/javascript" src="./js/jquery-3.4.1.js"></script>
    <script type="text/javascript" src="js/echarts.js"></script>
    <script type="text/javascript" src="./layer/layer.js"></script>


    <script>
        $(document).ready(function () {

            // var index = layer.load(0, {
            //     shade: [0.8, '#fff']
            // }); //0.1透明度的白色背景

            var num = GetQueryString('num') - 4;
            var projectid = GetQueryString('id');
            $("#tabHead").html(' ');
            $("#tabHead").html( tabHead(num) );

            $.ajax({
                type: "GET",
                dataType: "json",
                url: "http://112.74.169.99:21021/api/TokenAuth/GetProjectData?projectid=" + projectid,
                beforeSend: function (xhr) {
                    xhr.setRequestHeader("Accept", "application/json, text/javascript, */*; q=0.01");
                    xhr.setRequestHeader("Authorization", accessToken);
                    xhr.setRequestHeader('.AspNetCore.Culture', 'zh-Hans');
                },
                success: function (res) {
                    var data = res.result[num];
                    if (data.length == 0) {
                        layer.open({
                            type: 1,
                            content: '<div>' + '通讯异常' + '</div>',
                            btn: '确定',
                            btnAlign: 'c', //按钮居中
                            shade: 0, //不显示遮罩
                            yes: function () {
                                layer.closeAll();
                                layer.close(index);
                            }
                        });
                    } else {
                        

                        $("#khfxWarp").append(each(data));

                        var khfxPaneaa = $("#khfxWarp .khfxPaneaa");
                        $.each(khfxPaneaa,function (index,item) {
                            
                            $("#cyjpowerGeneration0"+index).html( dealnumber(data[index][1].powerGeneration) ); // 发电功率(柴油机)
                            $("#pcstap0"+index).html( dealnumber(data[index][2].tap) ); // PCS总有功功率(pcs)
                            $("#dbitap0"+index).html( dealnumber(data[index][4].itap) ); // 负载功率(电表总有功功率)
                            $("#emscountercurrentControl0"+index).html( dealnumber(data[index][0].backFlow) ); // 防逆流值(ems)
                            $("#bmssoc0"+index).html( dealnumber(data[index][3].soc) ); // soc(bms)
                            $("#bmssoh0"+index).html( dealnumber(data[index][3].soh) ); // soh(bms)

                            // 柴油机
                            $("#powerGeneration"+index).html( dealnumber(data[index][1].powerGeneration) ); // 发电功率
                            $("#fuelLevel"+index).html( dealnumber(data[index][1].fuelLevel) ); // 燃油位 百分比

                            // 智能电表
                            $("#itap"+index).html( dealnumber(data[index][4].itap) ); //总有功功率
                            $("#tpap"+index).html( dealnumber(data[index][4].tpap) ); //正向有功总电量


                            // PCS
                            $("#tap"+index).html( dealnumber(data[index][2].tap) ); //PCS总有功功率
                            $("#tApparentP"+index).html( dealnumber(data[index][2].tApparentP) ); //PCS总视在功率
                            $("#trp"+index).html( dealnumber(data[index][2].trp) ); //PCS总无功功率


                            // BMS
                            $("#soc"+index).html(dealnumber(data[index][3].soc)); //BMS SOC
                            $("#group_V"+index).html(dealnumber(data[index][3].group_V)); //BMS 堆总电压
                            $("#group_I"+index).html(dealnumber(data[index][3].group_I)); //BMS 堆总电流


                            // 温湿度
                            $("#temperature"+index).html( dealnumber(data[index][0].temperature) ); //板载温度
                            $("#environmentalT"+index).html( dealnumber(data[index][2].environmentalT) ); //环境温度
                            $("#cabinetT"+index).html( dealnumber(data[index][2].cabinetT) ); //模块温度
                            
                        })


                        


                        setInterval(updateData,1000);

                        
                        // layer.close(index);
                    }

                },
                error: function (err) {
                    console.log("首次请求数据 请求失败");
                }
            });

            // tab选项卡切换
            $("#tabHead.tabHead span").on("click", function () {
                var $this = $(this);
                var itemIndex = $this.index();
                $(this).addClass("active").siblings(".tabHead span").removeClass("active");
                $(".khfxPane").eq(itemIndex).show().siblings(".khfxPane").hide();
            });

            var num_index = 0;
            var pcs1_rp_1 = '';
            var pcs1_rp_2 = '';
            var pcs2_rp_1 = '';
            var pcs2_rp_2 = '';
            var xData = []; // x轴时间数据
            var yData1 = []; //实时发电功率的y轴数据
            var yData2 = []; //实时PCS功率的y轴数据
            var yData3 = []; //实时负载功率的y轴数据


            function updateData() { // 请求数据
                num_index++;
                var onoff = isPositiveNum(num_index / 15); //一分钟增加一次数据

                $.ajax({
                    type: "GET",
                    url: "http://112.74.169.99:21021/api/TokenAuth/GetProjectData?projectid=" + projectid,
                    success: function (res) {
                        var data = res.result[num];

                        var khfxPaneaa = $("#khfxWarp .khfxPaneaa");
                        $.each(khfxPaneaa,function (index,item) {
                            
                            $("#cyjpowerGeneration0"+index).html( dealnumber(data[index][1].powerGeneration) ); // 发电功率(柴油机)
                            $("#pcstap0"+index).html( dealnumber(data[index][2].tap) ); // PCS总有功功率(pcs)
                            $("#dbitap0"+index).html( dealnumber(data[index][4].itap) ); // 负载功率(电表总有功功率)
                            $("#emscountercurrentControl0"+index).html( dealnumber(data[index][0].backFlow) ); // 防逆流值(ems)
                            $("#bmssoc0"+index).html( dealnumber(data[index][3].soc) ); // soc(bms)
                            $("#bmssoh0"+index).html( dealnumber(data[index][3].soh) ); // soh(bms)

                            // 柴油机
                            $("#powerGeneration"+index).html( dealnumber(data[index][1].powerGeneration) ); // 发电功率
                            $("#fuelLevel"+index).html( dealnumber(data[index][1].fuelLevel) ); // 燃油位 百分比

                            // 智能电表
                            $("#itap"+index).html( dealnumber(data[index][4].itap) ); //总有功功率
                            $("#tpap"+index).html( dealnumber(data[index][4].tpap) ); //正向有功总电量


                            // PCS
                            $("#tap"+index).html( dealnumber(data[index][2].tap) ); //PCS总有功功率
                            $("#tApparentP"+index).html( dealnumber(data[index][2].tApparentP) ); //PCS总视在功率
                            $("#trp"+index).html( dealnumber(data[index][2].trp) ); //PCS总无功功率


                            // BMS
                            $("#soc"+index).html(dealnumber(data[index][3].soc)); //BMS SOC
                            $("#group_V"+index).html(dealnumber(data[index][3].group_V)); //BMS 堆总电压
                            $("#group_I"+index).html(dealnumber(data[index][3].group_I)); //BMS 堆总电流


                            // 温湿度
                            $("#temperature"+index).html( dealnumber(data[index][0].temperature) ); //板载温度
                            $("#environmentalT"+index).html( dealnumber(data[index][2].environmentalT) ); //环境温度
                            $("#cabinetT"+index).html( dealnumber(data[index][2].cabinetT) ); //模块温度
                            
                        })


                    },
                    error: function (err) {
                        console.log("项目状态参数 请求失败");
                    }
                });
            }


            function tabHead(num) {
                var str = ``;
                if(num === 0){
                    str += `
                        <span class="active" style="width:25%"><i>NDES03</i></span>
                        <span style="width:25%"><i>NDES04</i></span>
                        <span style="width:25%"><i>一次系统图</i></span>
                    `;
                }else if(num === 1){
                    str += `
                        <span class="active" style="width:25%"><i>NDES05</i></span>
                        <span style="width:25%"><i>NDES06</i></span>
                        <span style="width:25%"><i>一次系统图</i></span>
                    `;
                }else if(num === 2){
                    str += `
                        <span class="active" style="width:25%"><i>NDES07</i></span>
                        <span style="width:25%"><i>NDES08</i></span>
                        <span style="width:25%"><i>一次系统图</i></span>
                    `;
                }else if(num === 3){
                    str += `
                        <span class="active" style="width:25%"><i>NDES09</i></span>
                        <span style="width:25%"><i>NDES10</i></span>
                        <span style="width:25%"><i>一次系统图</i></span>
                    `;
                }
                
                return str;
            }


            function each(obj) {
                var str = '';
                if (obj.constructor==Array) {
                    for (var i = 0, len = obj.length; i < len; i++) {
                        str += `
                        <div class="khfxPane xmzt khfxPaneaa">
                            <div class="zt1 ztdetail" style="margin-top: 0.5rem;">
                                <ul>
                                    <li style="flex-basis: 0.8rem;">
                                        <p>发电功率</p>
                                        <div class="ztdiv">
                                            <span id="cyjpowerGeneration0`+i+`">0</span><span>kW</span>

                                        </div>
                                    </li>
                                    <li>
                                        <p>PCS功率</p>
                                        <div class="ztdiv">
                                            <span id="pcstap0`+i+`"></span><span>kW</span>
                                        </div>
                                    </li>
                                    <li style="flex-basis: 0.8rem;">
                                        <p>负载功率</p>
                                        <div class="ztdiv">
                                            <span id="dbitap0`+i+`"></span><span>kW</span>
                                        </div>
                                    </li>
                                </ul>
                                <ul>
                                    <li style="flex-basis: 0.8rem;">
                                        <p>防逆流值</p>
                                        <div class="ztdiv">
                                            <span id="emscountercurrentControl0`+i+`">0</span><span>kW</span>
                                        </div>
                                    </li>
                                    <li>
                                        <p>SOC</p>
                                        <div class="ztdiv">
                                            <span id="bmssoc0`+i+`">0</span><span>%</span>
                                        </div>
                                    </li>
                                    
                                    <li style="flex-basis: 0.8rem;">
                                        <p>SOH</p>
                                        <div class="ztdiv">
                                            <span id="bmssoh0`+i+`"></span><span>%</span>

                                        </div>
                                    </li>
                                    
                                </ul>
                            </div>

                            <div class="zt2 ztdetail">
                                <div class="detail_tit">
                                    <img src="./images/arrows_blue.svg" alt="" />
                                    <span>柴油机</span>
                                </div>
                                <ul>
                                    <li style="flex-basis: 1.4rem;">
                                        <p>发电功率</p>
                                        <div class="ztdiv">
                                            <span id="powerGeneration`+i+`">0</span><span>kW</span>
                                        </div>
                                    </li>
                                    <li>
                                        <p>燃油位</p>
                                        <div class="ztdiv">
                                            <span id="fuelLevel`+i+`">0</span><span>%</span>
                                        </div>
                                    </li>
                                </ul>
                            </div>

                            <div class="zt2 ztdetail">
                                <div class="detail_tit">
                                    <img src="./images/arrows_blue.svg" alt="" />
                                    <span>智能电表</span>
                                </div>
                                <ul>
                                    <li>
                                        <p>总有功功率</p>
                                        <div class="ztdiv">
                                            <span id="itap`+i+`">0</span><span>kW</span>
                                        </div>
                                    </li>
                                    <li style="flex-basis: 1.4rem;">
                                        <p>正向有功总电量</p>
                                        <div class="ztdiv">
                                            <span id="tpap`+i+`">0</span><span>kWh</span>
                                        </div>
                                    </li>
                                </ul>
                            </div>

                            <div class="zt2 ztdetail">
                                <div class="detail_tit">
                                    <img src="./images/arrows_orange.svg" alt="" />
                                    <span>PCS</span>
                                </div>
                                <ul>
                                    <li>
                                        <p>总有功功率</p>
                                        <div class="ztdiv">
                                            <span id="tap`+i+`">0</span><span>kW</span>
                                        </div>
                                    </li>
                                    <li>
                                        <p>总视在功率</p>
                                        <div class="ztdiv">
                                            <span id="tApparentP`+i+`">0</span><span>kVA</span>
                                        </div>
                                    </li>
                                    <li>
                                        <p>总无功功率</p>
                                        <div class="ztdiv">
                                            <span id="trp`+i+`">0</span><span>kVar</span>
                                        </div>
                                    </li>
                                </ul>
                            </div>


                            <div class="zt2 ztdetail">
                                <div class="detail_tit">
                                    <img src="./images/arrows_green.svg" alt="" />
                                    <span>BMS</span>
                                </div>
                                <ul>
                                    <li>
                                        <p>SOC</p>
                                        <div class="ztdiv">
                                            <span id="soc`+i+`">0</span><span>%</span>
                                        </div>
                                    </li>
                                    <li>
                                        <p>总电压</p>
                                        <div class="ztdiv">
                                            <span id="group_V`+i+`">0</span><span>v</span>
                                        </div>
                                    </li>
                                    <li>
                                        <p>总电流</p>
                                        <div class="ztdiv">
                                            <span id="group_I`+i+`">0</span><span>A</span>
                                        </div>
                                    </li>
                                </ul>
                            </div>

                            
                            <div class="zt3 ztdetail">
                                <div class="detail_tit">
                                    <img src="./images/arrows_blue.svg" alt="" />
                                    <span>温湿度</span>
                                </div>
                                <ul>
                                    <li>
                                        <p>板载温度</p>
                                        <div class="ztdiv">
                                            <span id="temperature`+i+`">0</span><span>℃</span>
                                        </div>
                                    </li>
                                    
                                    <li>
                                        <p>环境温度</p>
                                        <div class="ztdiv">
                                            <span id="environmentalT`+i+`">0</span><span>℃</span>
                                        </div>
                                    </li>
                                    <li>
                                        <p>模块温度</p>
                                        <div class="ztdiv">
                                            <span id="cabinetT`+i+`">0</span><span>℃</span>
                                        </div>
                                    </li>
                                </ul>
                            </div>

                        </div>

                        `;
                    }
                    return str;
                }
                if (obj.constructor==Object) {
                    console.log("对象");
                    for (var i in obj) {
                        // var str;
                        str += '<span class="data_show"><span data-id='+obj[i].community_id+'>' + obj[i].community_name + '</span><span class="del glyphicon glyphicon-plus-sign"></span></span>';
                    }
                    return str;
                }
                return obj;
            }

        });
    </script>
</body>

</html>